import { createApp } from 'vue'

import {router} from './router'
import progress from './utils/nprogress'
import ElementPlus from 'element-plus'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'

import 'element-plus/dist/index.css'

import 'virtual:windi.css'
import 'nprogress/nprogress.css'
import './style.scss'

import App from './App.vue'

import defaultSettings from './config'
import messageInfo from "@/utils/message.js";
import cookies from "@/utils/auth.js";

import store from './store'
import './permission'

//全局自定义指令，用于权限控制：接口及按钮拦截显示
import interceptor from './directives/interceptor'

//全局校验
import validator from '@/utils/validator'

//数据处理
import dataTrans from '@/utils/dataTrans'

//自定义createApp返回结果
const app=createApp(App)
app.use(router)
app.use(ElementPlus)
app.use(store)
app.use(interceptor)

//全局变量
app.config.globalProperties.$settings=defaultSettings
app.config.globalProperties.$messageInfo=messageInfo
app.config.globalProperties.$cookies=cookies
app.config.globalProperties.$progress=progress
app.config.globalProperties.$validator=validator
app.config.globalProperties.$dataTrans=dataTrans

//引入element图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

app.mount('#app')
